package two_shang._9_18;

import java.util.Objects;

//练习枚举
public enum SexEnum {

    //    这里先用逗号再最后才是分号.
    BOY(0, "男"),
    GIRL(1, "女"),
    OTHERS(2, "保密");


    private Integer code;
    private String description;


    public static SexEnum getByCode(Integer code) {
        for (SexEnum e : SexEnum.values()) {
            if (Objects.equals(code, e.getCode())) {
                return e;
            }
        }
        return null;
    }

    SexEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}
